package com.cspg.ssss.controller;

import com.cspg.ssss.service.SelectWenTiService;
import com.cspg.ssss.vo.ResultVo;
import com.cspg.ssss.vo.ResultVoUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/selectwenti")
public class SelectWenTiController {
    @Autowired
    private SelectWenTiService selectWenTiService;

    /**
     * wtlb 问题类别 公司/单位
     */
    @PostMapping(value = "/selectwtsxlist")
    public ResultVo selectst(@RequestBody Map<String, Object> map) {
        PageInfo<Map> list = selectWenTiService.selectwemti(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    @GetMapping(value = "/selectwtsxdwlist")
    public ResultVo selectwtsxdwlist(@RequestBody Map<String, Object> map) {
        List<Map> list = selectWenTiService.selectwemtidw(map);
        return ResultVoUtil.success("查询成功", list, "400");
    }

    @GetMapping(value = "/wentigz")
    public ResultVo selectwtsxdwlist(@RequestParam("id") String id) {
        List<Map> list = selectWenTiService.selectdeptrectify(id);
        Map map = new HashMap();
        String shenhe;
        if (list.size() > 0) {
            if ("".equals(list.get(0).get("flow_type")) || list.get(0).get("flow_type") == null) {
                shenhe = "";
            } else {
                shenhe = list.get(0).get("flow_type").toString();
            }
            map.put("oneortwo", shenhe);
        }
        List<Map> list2 = selectWenTiService.selectgz(id);
        map.put("genz", list2);
        return ResultVoUtil.success("查询成功", map, "400");
    }
}
